Skip to content

fix(transaction-pay-controller): use Infura endpoint for live token balance queries#8839

Open
matthewwalsh0 wants to merge 12 commits into
mainfrom
fix/pay-infura-balance-nonce
Open

fix(transaction-pay-controller): use Infura endpoint for live token balance queries#8839
matthewwalsh0 wants to merge 12 commits into
mainfrom
fix/pay-infura-balance-nonce

Conversation

@matthewwalsh0
Copy link
Copy Markdown
Member

@matthewwalsh0 matthewwalsh0 commented May 18, 2026

Explanation

When querying a live on-chain token balance, the controller previously resolved the network client using findNetworkClientIdByChainId, which returns whatever endpoint is currently selected for that chain — including custom RPC endpoints. Custom RPC endpoints may not support the pending block tag used by these calls, causing the query to fail.

This change adds a preference for the chain's Infura endpoint when one is configured, falling back to the existing findNetworkClientIdByChainId behaviour if no Infura endpoint is configured or if the lookup throws.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Changes which RPC endpoint serves balance validation and on-chain amount reads for pay/relay flows; behavior is mitigated by fallback to the default network client when Infura is missing.

Overview
Introduces shared getNetworkClientId / rpcRequest helpers that can prefer a chain’s Infura RPC (via NetworkController:getNetworkConfigurationByChainId) and otherwise fall back to the selected network client.

getLiveTokenBalance now uses direct JSON-RPC (eth_call / eth_getBalance with pending) through those helpers with preferInfura: true, replacing ethers Web3Provider/Contract—aimed at custom RPCs that don’t support pending block tags.

On-chain amount resolution for fiat flows and getTransferredAmountFromTxHash is updated to the same provider-based RPC path. Across, Relay submit, and gas estimation use getNetworkClientId without the Infura preference. Tests and the test messenger mock getNetworkConfigurationByChainId accordingly.

Reviewed by Cursor Bugbot for commit 2472294. Bugbot is set up for automated code reviews on this repo. Configure here.

@matthewwalsh0 matthewwalsh0 force-pushed the fix/pay-infura-balance-nonce branch 4 times, most recently from 77eee8b to a9de394 Compare May 18, 2026 14:14
@matthewwalsh0 matthewwalsh0 force-pushed the fix/pay-infura-balance-nonce branch from 4c70b63 to 8350c8e Compare May 27, 2026 23:14
@matthewwalsh0 matthewwalsh0 force-pushed the fix/pay-infura-balance-nonce branch from aa7c99a to 2b7b6e0 Compare May 29, 2026 21:01
@matthewwalsh0 matthewwalsh0 marked this pull request as ready for review May 29, 2026 23:23
@matthewwalsh0 matthewwalsh0 requested review from a team as code owners May 29, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant